package com.neusoft.neuhealth.controller;

import com.neusoft.neuhealth.email.LoginParam;
import com.neusoft.neuhealth.email.R;
import com.neusoft.neuhealth.po.Result;
import com.neusoft.neuhealth.po.common.result.Notification;
import com.neusoft.neuhealth.service.CommonService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Tag(name = "邮箱验证接口")
@RestController
@RequestMapping("/common")
@CrossOrigin
public class CommonController {

    @Autowired
    private CommonService commonService;

    // 权限码请求接口
    @Operation(summary = "权限码请求接口")
    @PostMapping("/code/request")
    public R getRequestPermissionCode(@RequestBody String emailJson) {
        return commonService.getRequestPermissionCode(emailJson);
    }

    // 邮箱验证码接口
    @Operation(summary = "邮箱验证码接口")
    @PostMapping("/code/email")
    public R sendEmailCode(@RequestBody LoginParam loginParam) {
        return commonService.sendEmailCode(loginParam);
    }

    //重置密码接口
    @Operation(summary = "重置密码接口")
    @PostMapping("/code/findPassword")
    public R findPassword(@RequestBody LoginParam loginParam) {
        return commonService.findPassword(loginParam);
    }

    @Operation(summary = "获取通知信息")
    @GetMapping("/notification")
    public Result<Notification> getNotification(String date){
        return commonService.getNotification(date);
    }

}
